#include <bits/stdc++.h>

using namespace std;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool is_val(int n)
{
    int year = n / 10000;
    int month = n % 10000 / 100;
    int day = n % 100;
    if (month <= 0 || month >= 13)
    {
        return false;
    }
    if (month != 2 && day > days[month])
    {
        return false;
    }
    if (month == 2)
    {
        if (year %4 == 0 && year % 100 != 0 || year %400 == 0)
        {
            if (day > 29)
            {
                return false;
            }
        }
    }
    return true;
}

int main()
{
    int data1, data2, count = 0;
    cin >> data1 >> data2;
    for (int i = 1000; i < 10000; ++i)
    {
        int x = i, r = i;
        for (int j = 0; j < 4; ++j)
        {
            r = r * 10 + x % 10;
            x /= 10;
        }
        if (r >= data1 && r <= data2 && is_val(r))
            ++count;
    }
    cout << count << endl;
    return 0;
}